package com.back.controller;

import com.back.domain.SysRole;
import com.back.domain.VO.SYSTEM.SysRolePagingBody;

import com.back.service.SysRoleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sysRole")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    
    @GetMapping
    public IPage<SysRole> getList(@RequestBody SysRolePagingBody pagingBody){

//        为页数和条数添加默认值
        if (pagingBody.getPageSize()==null||pagingBody.getPageNum()==null) {
            // 设置默认值
            pagingBody.setPageNum(1);
            pagingBody.setPageSize(10);
        }
        pagingBody.setLimit(pagingBody.getPageSize());
        pagingBody.setOffset((pagingBody.getPageNum()-1)* pagingBody.getPageSize());
        System.out.println(pagingBody);
        return sysRoleService.SelectData(pagingBody);
    }
}
